(function() {

this.pasta = this.pasta || {};
this.pasta.webgui = this.pasta.webgui || {};

this.pasta.webgui.ImagePushButton = pasta.webgui.Control.extend(
{
	init : function() 
	{
		this._super();
		
		this.canvas.style.background = "url(img/control/checkBox/checkBox.png)";
		this.canvas.style.backgroundPosition = "left top";
		
		var obj = this;
		this.canvas.onmousedown = function() { obj.doMouseDown(); };
		this.canvas.style.cursor = "pointer";
		
		this.setWidth(16);
		this.setHeight(16);
		
		this.selected = false;
		this._onChange = null;
	},
	
	//------------------ Event Handler -----------------
	
	doMouseDown : function()
	{
		this.setSelected(!this.selected);
		
		this._super();
		
		if (this._onChange != null)
			this._onChange.callHandler(this);
	},
	
	//------------------ Setter & Getter -----------------
	
	setImage : function(data)
	{
		this.canvas.style.background = "url(" + data + ") no-repeat";
	},
	
	isSelected : function()
	{
		return this.selected;
	},
	
	setSelected : function(data)
	{
		this.selected = data;
		this.canvas.style.backgroundPosition = this.selected ? "left bottom" : "left top";
	},
	
	//------------------ Event -----------------
	
	getOnChange : function()
	{
		if (this._onChange == null)
			this._onChange = new pasta.util.EventObj();
		
		return this._onChange;
	}
});

})();